﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.IO;
using NPMonitor.DataModel;

namespace NPMonitor.Interfaces
{
    public interface IJobDefinitionStore
    {
        #region Job Definition Methods

        IList<JobDefinition> GetAllJobDefinitions(Expression<Func<JobDefinition, bool>> queryExpression);

        /// <summary>
        /// Get All Jobs
        /// </summary>
        /// <returns></returns>
        List<JobDefinition> GetAllJobDefinitions(int pageIndex, int pageSizes);

        JobFileInfo RetrieveJobFileInfo(HttpPostedFile postedFile);

        void SaveJobDefinition(JobDefinition jobDefinition);

        void SaveJobDefinition(JobDefinition jobDefinition, string tmpFileName, params Scenario[] scenarios);

        /// <summary>
        /// Delete Job By Id
        /// </summary>
        /// <param name="id"></param>
        void DeleteJobDefinitionById(int id);

        /// <summary>
        /// Get Total Jobs Count
        /// </summary>
        /// <returns></returns>
        int GetJobDefinitionTotalCount();

        /// <summary>
        /// 根据job id 获取job 定义信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        JobDefinition GetJobDefinitionById(int id);

        /// <summary>
        /// get job definition by job name;
        /// </summary>
        /// <param name="jobName"></param>
        /// <returns></returns>
        JobDefinition GetJobDefinitionByJobName(string jobName);

        ValidationResult ValidateJobDefinition(JobDefinition jobDefinition);

        List<JobDefinition> GetJobDefinitionByFoggyName(string foggyName);

        #endregion

        #region Scenarios Methods

        IList<Scenario> GetAllScenarios(Expression<Func<Scenario, bool>> queryExpression);

        ValidationResult ValidateScenario(Scenario scenario);

        void SaveScenario(Scenario scenario);

        Scenario GetScenario(int scenarioId);

        Scenario GetScenarioByNo(string scenarioNo);

        IList<Scenario> GetScenarios(int? jobId, int pageIndex = 0, int pageSizes = int.MaxValue);

        IList<Scenario> GetEnableScenarios(int jobId);

        int GetScenariosTotalCount(int? jobId);

        #endregion

    }
}
